package com.changli05.objectstream;

import org.junit.Test;

import java.io.File;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class ObjectInputOutputStreamTest {
    @Test
    public void testObjectOutputStream() throws Exception {
        File file = new File ("object.txt");
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));
        oos.writeUTF("饿了，想吃饭了");
        oos.flush();
        oos.close();

    }
    @Test
    public void testObjectInputStream() throws Exception {
        File file = new File ("object.txt");
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));

        Object obj =ois.readUTF();
        System.out.println(obj);
        ois.close();

    }

}
